package Operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找书籍");
        System.out.println("请输入想要查找的书籍名称");
        Scanner in = new Scanner(System.in);
        String name = in.nextLine();
        for (int i = 0; i < bookList.getBookSize(); i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)) {
                System.out.println("找到了");
            }else {
                System.out.println("没有这本书");
                System.out.println(book.toString());
            }
        }
    }
}
